// 定义默认状态
const defaultState = {
    // loading的显示隐藏
    showLoading: false,
    // 弹框提示
    showAlert: false,
    // 弹框类型  success | info | warning | error
    alertType: "success",
    // 弹框内容
    alertContent: "弹框内容"
}


// 导出一个函数
// eslint-disable-next-line
export default (state = defaultState, action) => {
    let newState = JSON.parse(JSON.stringify(state));
    switch (action.type) {
        // 控制loading显示
        case "showLoadingFn":
            newState.showLoading = true;
            break;
        // 控制loading隐藏
        case "hideLoadingFn":
            newState.showLoading = false;
            break;
        // 控制Alert显示
        case "showAlert":
            newState.showAlert = true;
            newState.alertType = action.value.alertType;
            newState.alertContent = action.value.alertContent;
            break;
        // 控制Alert隐藏
        case "hideAlert":
            newState.showAlert = false;
            break;
        default:
            break;
    }
    return newState;
}